package main

import "fmt"

func main(){
	// defer fmt.Println("deferred main")
	// defer fmt.Println("defer help you to close file")
	defer recoverSayHi()
	sayHi("")
 	fmt.Println("end!!")
}

func sayHi(name string){
	//arr := []int{1,2,3}
	fmt.Println("Open a file")
	//defer recoverSayHi()
	if len(name)<1{
		//fmt.Println(arr[5])
		panic("hahaha")
	}
	fmt.Println("hi", name)
	fmt.Println("bla,bla")
	fmt.Println("Close a file")
}

func recoverSayHi(){
	fmt.Println("you can clean")
	if r := recover(); r!=nil{
		fmt.Println("recoved from", r)
	}

}
